<template>
	<view class="content">
		<view style="width: 100%;height: 20rpx;background-color: #F8F8F8;">

		</view>
		<view style="width: 100%;height: auto;background-color: white;">
			<view v-for="(l,i) in listData" :key="i">
				<view class="cell" v-if="l.days < 0" @click="toStudy(l.title0+':'+ l.title,l.id,l.jump_id)">
					<view class="cellfoot">
						<image class="playicon" :src="l.type == '课程' ? playcircle : zhibo">
						</image>
						<view class="foottag">
							{{l.title}}
						</view>
					</view>
				</view>
				<view class="cell" v-else>
					<view class="celltime">
						<view class="timetag">
						</view>
						<view class="time">
							{{l.date}}
						</view>
					</view>
					<view class="cellfoot" @click="toStudy(l.title0+'：'+ l.title,l.id,l.jump_id)">
						<image class="playicon" :src="l.type == '课程' ? playcircle : zhibo">
						</image>
						<view class="foottag">
							{{l.title0+'：'+ l.title}}
						</view>

						<view v-if="l.type == '课程'">
							<view class="sign" v-if="l.is_daka == 0">
								学习<br>打卡
							</view>
							<view class="signdaka" v-else>
								<image :src="todaydaka" style="width: 66rpx;height: 66rpx;">
							</view>
						</view>

						<view v-else>
							<view class="sign" v-if="l.is_daka == 0">
								直播<br>预约
							</view>
							<view class="signyuyue" v-else>
								<image :src="todayyuyue" style="width: 75.24rpx;height: 66rpx;">
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="">
			<view style="padding-left: 20rpx;padding-top: 20rpx;">
				全部动态
			</view>
			<dynamic ref="dynamic" :bootId="bootId" :userId="userId" :token="token">
			</dynamic>
		</view>

	</view>
</template>

<script>
	import animationType from '@/utils/animationType.js';
	import dynamic from '../../workshop/components/dynamic.vue';
	import {
		getBootcampArrange
	} from '@/api/camp.js';
	import {
		number
	} from 'zod';
	export default {
		components: {
			dynamic
		},
		props: {
			bootId: {
				type: String,
				required: true,
				default: ''
			},
			userId: {
				type: String,
				required: true,
				default: ''
			},
			token: {
				type: String,
				required: true,
				default: ''
			},
			learn: {
				type: Number,
				required: true,
				default: ''
			},
		},
		data() {
			return {
				zhibo: require('../../../static/images/workshop/zhiboicon.png'),
				playcircle: require('../../../static/images/workshop/playcircle.png'),
				todaydaka: require('../../../static/images/workshop/todaydaka.png'),
				todayyuyue: require('../../../static/images/workshop/todayyuyue.png'),
				listData: [],
			}
		},
		mounted() {
			let that = this;
			// uni.$on('pageScroll', (scrollTop) => {
			// 	console.log('---scrollTop=== ', scrollTop);
			// 	if (scrollTop > 300) { // 滚动超过300时吸顶
			// 		that.stickyStyle = 'position: fixed; top: 0; width: 100%; z-index: 999;';
			// 	} else {
			// 		that.stickyStyle = '';
			// 	}
			// });
			that.getBoot();
		},
		onPageScroll(res) {
			console.log('####  ' + res.scrollTop)
		},
		created() {
			uni.$on('refreshCommentList', this.refreshList);
		},
		beforeDestroy() {
			uni.$off('refreshCommentList'); // 避免内存泄漏
		},
		methods: {
			bottomGet() {
				let that = this;
				that.$refs.dynamic.bottomRequest();
			},
			refreshList() {
				let that = this;
				console.log('@@@&&&&  ----')
				that.getBoot();
			},
			getBoot() {
				let that = this;
				let p = {};
				p.userId = that.userId;
				p.token = that.token;
				p.bootId = that.bootId;
				getBootcampArrange(p).then(res => {
					if (res.code == 0) {
						that.listData = [];
						that.listData = res.data;
					}
				})
			},
			toStudy(title, id, jumpId) {
				let that = this;
				console.log('===___' + that.bootId)
				if (that.learn == 1) {
					uni.navigateTo({
						animationType: animationType.type,
						animationDuration: animationType.duration,
						url: '/pages/dailystudy/dailystudy?bootId=' + that.bootId + '&userId=' + that.userId +
							'&token=' + that.token +
							'&dyTitle=' + title +
							'&hwId=' + id +
							'&jumpId=' + jumpId,
					})
				} else {
					uni.showToast({
						title: "您尚未开通体验营学习权限，简介下方联系老师开通",
						icon: 'none'
					})
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	body,
	html {
		background: white;
	}

	.content {
		height: 100vh;
		background: white;
	}

	.cell {
		display: grid;
	}

	.cellhead {
		display: flex;
		align-items: center;
		height: 50px;
		line-height: 50rpx;
		border-radius: 16rpx;
		margin: 10rpx 20rpx;
		width: calc(100% - 40rpx);
		background-color: rgb(255, 245, 231);
		padding-left: 20rpx;
		padding-right: 20rpx;

		image {
			width: 40rpx;
			height: 40rpx;
		}

		.headtitle {
			margin-left: 20rpx;
			font-size: 26rpx;
			color: #1F2642;
		}
	}

	.celltime {
		display: flex;
		align-items: center;
		height: 30px;
		margin: 0rpx 40rpx;
		width: calc(100% - 80rpx);
		line-height: 30rpx;
		background-color: white;
		padding-left: 20rpx;
		padding-right: 20rpx;

		.timetag {
			width: 6rpx;
			height: 20rpx;
			background-color: rgb(255, 125, 43);
		}

		.time {
			margin-left: 10rpx;
		}
	}

	.cellfoot {
		display: flex;
		align-items: center;
		height: 50px;
		line-height: 50rpx;
		border-radius: 16rpx;
		margin: 10rpx 20rpx;
		width: calc(100% - 40rpx);
		background-color: rgb(255, 245, 231);
		padding-left: 40rpx;
		padding-right: 20rpx;

		.playicon {
			width: 40rpx;
			height: 40rpx;
			margin-right: 20rpx;
		}

		.foottag {
			font-size: 24rpx;
			// line-height: 36rpx;
			font-weight: 600;
			width: 500rpx;
		}

		.foottitle {
			margin-left: 20rpx;
			font-size: 22rpx;
			color: #1F2642;
		}

		.sign {
			height: 66rpx;
			width: 66rpx;
			margin: 20rpx 10rpx 20rpx 20rpx;
			font-size: 20rpx;
			line-height: 22rpx;
			border-radius: 33rpx;
			background-color: rgb(255, 128, 41);
			color: white;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: auto
		}

		.signdaka {
			height: 100%;
			width: 100%;
			//margin: 20rpx 10rpx 20rpx 20rpx;
			//background-color: rgb(255, 128, 41);
			color: white;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: auto
		}

		.signyuyue {
			height: 100%;
			width: 100%;
			margin: 20rpx 10rpx 20rpx 20rpx;
			//background-color: rgb(255, 128, 41);
			color: white;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: auto
		}
	}
</style>